/**
 *  Copyright (C) 2006 zhangbo (freeeob@gmail.com)
 *
 *  This product is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; either version 2.1 of the License, or
 *  (at your option) any later version.
 * 
 *  This product is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 * 
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 *
 *  author:zhangbo
 *  Email:jsjava@gmail.com
 */

/**
 * Constrcutor
 */ 
function JSArrayUtils(){
	this.jsjava_class="jsorg.eob.lang.JSArrayUtils";	
}

JSArrayUtils.countValue=function(arr,value){
	if(!(arr instanceof Array)){
		return;
	}
	var count=0;
	for(var i=0;i<arr.length;i++){
		if(arr[i]==undefined){
			if(arr[i]==value){
				count++;
			}
		}else{
			if(arr[i]==value){
				count++;
			}
		}
	}
	return count;
};

JSArrayUtils.countValues=function(arr){
	if(!(arr instanceof Array)){
		return;
	}
	var map=new HashMap();
	for(var i=0;i<arr.length;i++){
		var value=arr[i];
		if(map.containsKey(value)){
			var count=map.get(value);
			count++;
			map.put(value,count);
		}else{
			map.put(value,1);
		}
	}
	return map;
};